package com.servlet.web;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @Title: GertAreaServlet
 * @Description:
 * @Auther: py
 * @Version: 1.0
 * @create 2023/12/26 10:21
 */
@WebServlet("/get")
public class GertAreaServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HttpSession session = req.getSession();
        ServletContext servletContext = req.getServletContext();

        Object userrequest = req.getAttribute("userrequest");
        System.out.println("request"+userrequest);
        // 替换
        session.setAttribute("usersession","######");
        Object usersession = session.getAttribute("usersession");
        System.out.println("session"+usersession);
        Object usercontext = servletContext.getAttribute("usercontext");
        System.out.println("context"+usercontext);

        resp.getWriter().write("success!");
    }
}
